public class Solution747 {
    public int dominantIndex(int[] nums) {
        int max=0;
        int pos=-1;
        for (int i=0;i<nums.length;i++){
            if (nums[i]>max){
                max=nums[i];
                pos=i;
            }
        }
        for (int num : nums) {
            if (num!=max){
                if (num*2>max){
                    return -1;
                }
            }
        }
        return pos;
    }

    public static void main(String[] args) {
        System.out.println(new Solution747().dominantIndex(new int[]{3,6,1,0}));
    }
}
